#include <set>

#include <QGuiApplication>
#include <QClipboard>

#include "SendPointHandlerBase.h"
#include "PosHandler.h"
#include "SelectHandler3D.h"
#include "QtOSGWidget.h"
#include "Qt3DPicker.h"
#include "CmdManager.h"

PosHandler::PosHandler()
	: m_snapPointFlag(0)
{
}

PosHandler::~PosHandler()
{
	auto sph = getSendPointHandler();
	if (sph)
		sph->setSnapPointFlag(m_snapPointFlag);
}

void PosHandler::input(const QVariant& data, const QString& rawInput, CommandSource cs)
{
	if (data.type() == QVariant::Bool)
	{
		emit finished();
		return;
	}

	auto sph = getSendPointHandler();
	if (status() == 0)
	{
		enableMouseHandler(MouseHandlerID::PointSender);
		if (sph)
		{
			sph->setPointMask(CS_LBTNDOWN | CS_MOUSEMOVE);
			m_snapPointFlag = sph->getSnapPointFlag();
			sph->setSnapPointFlag(SnapPointObject);
		}
		else
		{
			emit finished();
			return;
		}
		prompt(1, tr("点坐标: "));
		return;
	}

	if (status() == 1)
	{
		return;
	}
}
